package com.linwen.tips.tools;

import com.linwen.tips.tools.bean.UserInfoReq;
import org.springframework.stereotype.Component;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Component
public class RegisterServiceImpl {
    private static final String EMAIL_REGEX =
            "^[A-Za-z0-9+_.-]+@(.+)$";

    public boolean registerUser(UserInfoReq userInfo) {
        String email = userInfo.getEmail();
        Pattern pattern = Pattern.compile(EMAIL_REGEX);
        Matcher emailMatcher = pattern.matcher(email);
        if (!emailMatcher.matches()) {
            System.out.println("Invalid email address.");
            return false;
        }

        // 进行其他用户注册逻辑，比如保存用户信息到数据库等
        // 返回注册结果
        return true;
    }
}